package edu.sctu.practice.chengongsuo.network;

import com.google.common.base.Charsets;
import com.google.common.io.Files;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

public class DemoClient {

    public static void main(String[] args) {


        try {
            Document document = Jsoup.connect("http://www.sctu.edu.cn/new_class.asp?type=news&class=1").get();

            Elements elements = document.select("div.list  li");


            File file = new File("D:\\demo.txt");

            for(Element e : elements){

                String title = e.select("a").text();
                title += "\r\n";

                Files.append(title, file, Charsets.UTF_8);

            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
